This is a small html file created with R Markdwown and the leaflet package for the assignment for week 2 of the Developing Data Products course. This course is part of the Data Science Specialization on Coursera.org (https://www.coursera.org/specializations/jhu-data-science/).
This year my wife and I went for a walk along the West Highland Way, in Scotland. We started somewhere in the middle (Tyndrum) and walked to Fort William. During our stay in Fort William, we climbed Ben Nevis, the highest moutain in Great Britain.
From the walk, I recorded the GPS track and this track is shown in the map below.
Some parts we travelled by bus. These tracks are not shown in the map.
Below the code is shown, so one can see this page is made with R and the leaflet package.
library(leaflet)
library(rgdal)
# read .gpx info
WHW_tracks <- readOGR("./Data/201706_Scotland_WHW.gpx", verbose = FALSE, layer = "tracks")
WHW_waypoints <- readOGR("./Data/201706_Scotland_WHW.gpx", verbose = FALSE, layer = "waypoints")
# Combine some info for links
link_popup <- paste("<a href=\"", WHW_waypoints$link1_href,
"\">", WHW_waypoints$cmt, "</a>", sep = "")
# Correct if link1_href is NA
link_popup[is.na(WHW_waypoints$link1_href)] <- as.character(WHW_waypoints$cmt[is.na(WHW_waypoints$link1_href)])
# Create icons from pictures, make it a list for future referencing by name
iconSize = 24
BmapIcons <- iconList(
"Ben Nevis" = makeIcon("./Data/Ben nevis.png",
"./Data/Ben nevis.png", iconSize, iconSize),
"Berkeley Guest House" = makeIcon("./Data/Berkeley Guest House.png",
"./Data/Berkeley Guest House.png", iconSize, iconSize),
"Heatherlea B&B" = makeIcon("./Data/Heatherlea B&B.png",
"./Data/Heatherlea B&B.png", iconSize, iconSize),
"Hermon B&B" = makeIcon("./Data/Hermon B&B.png",
"./Data/Hermon B&B.png", iconSize, iconSize),
"Kingshouse Hotel" = makeIcon("./Data/Kingshouse Hotel.png",
"./Data/Kingshouse Hotel.png", iconSize, iconSize),
"Tyndrum Inn" = makeIcon("./Data/Tyndrum Inn.png",
"./Data/Tyndrum Inn.png", iconSize, iconSize)
)
Bmap <- leaflet() %>%
addTiles() %>%
setView(lng = -5, lat = 56.62, zoom = 10) %>% # map location
addPolylines(data = WHW_tracks, color = "red", weight = 4) %>%
addMarkers(data = WHW_waypoints,
icon = ~BmapIcons[WHW_waypoints$name],
popup = link_popup)
Bmap